﻿using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;

namespace DFGK_WMS.WebAPI.Filter
{
    public class LogActionFilter : ActionFilterAttribute
    {
        private readonly ILogger<LogActionFilter> logger;
        public LogActionFilter(ILogger<LogActionFilter> logger)
        {
            this.logger = logger;
        }

        public override void OnActionExecuting(ActionExecutingContext context)
        {
            base.OnActionExecuting(context);
            //string? controllerName = context.RouteData.Values["controller"]?.ToString();
            //string? actionName = context.RouteData.Values["action"]?.ToString();
            //string httpMethod = context.HttpContext.Request.Method;
            Console.WriteLine("请求前："+JsonConvert.SerializeObject(context.ActionArguments.Values));
        }
        public override void OnResultExecuted(ResultExecutedContext context)
        {
            base.OnResultExecuted(context);
            Console.WriteLine("请求后"+context);
        }
    }
}
